home *** CD-ROM | disk | FTP | other *** search
/ SGI Developer Toolbox 6.1 / SGI Developer Toolbox 6.1 - Disc 4.iso / src / demos / demobook / interfmotif.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-08-02  |  4.6 KB  |  191 lines

  1. /*
  2.  * Copyright (C) 1993, 1994, Silicon Graphics, Inc.
  3.  * All Rights Reserved.
  4.  *
  5.  * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, Inc.;
  6.  * the contents of this file may not be disclosed to third parties, copied or
  7.  * duplicated in any form, in whole or in part, without the prior written
  8.  * permission of Silicon Graphics, Inc.
  9.  *
  10.  * RESTRICTED RIGHTS LEGEND:
  11.  * Use, duplication or disclosure by the Government is subject to restrictions
  12.  * as set forth in subdivision (c)(1)(ii) of the Rights in Technical Data
  13.  * and Computer Software clause at DFARS 252.227-7013, and/or in similar or
  14.  * successor clauses in the FAR, DOD or NASA FAR Supplement. Unpublished -
  15.  * rights reserved under the Copyright Laws of the United States.
  16.  */
  17. #include <stdio.h>
  18. #include <X11/Intrinsic.h>
  19. #include <X11/StringDefs.h>
  20. #include "exinterfmotif.h"
  21. #include <string.h>
  22. #include "exglobals.h"
  23.  
  24. extern Widget create_DupIcons();
  25. extern Widget create_AskDupIcons();
  26. Widget CreateGroup;
  27. Widget Index_w;
  28. Widget AskDupIcons_w;
  29. Widget DupIcons_w;
  30. Widget Quit_w;
  31.  
  32. init_motif_interface(argc, argv)
  33.         unsigned int argc;
  34.         char **argv;
  35. {
  36.     int i,j;
  37.  
  38.     /*------------------------------*/
  39.     /*     Initialize X         */
  40.     /*------------------------------*/
  41.  
  42.  
  43.     UxDisplay = XtDisplay(DBtoplevel);
  44.     UxScreen = XDefaultScreen(UxDisplay);
  45.     XtVaSetValues(DBtoplevel,
  46.             XtNx, 0,
  47.             XtNy, 0,
  48.             XtNwidth, DisplayWidth(UxDisplay, UxScreen),
  49.             XtNheight, DisplayHeight(UxDisplay, UxScreen),
  50.             NULL);
  51.  
  52.     MotifGroupWin = -1;
  53.     MSwin = -1;
  54.     InterfaceWinOpen = 0;
  55.     DialogType = 0;
  56.     WantToEnterFilesFlag = True;
  57.  
  58.     ExistKeywordString = (char *)malloc( sizeof(char) * 1024);
  59.     ExistKeywordString[0] = '\0';
  60.     ExistKeywordCount = 1;
  61.     strcat(ExistKeywordString, "8 bit");
  62.     GroupKeywordString = (char *)malloc( sizeof(char) * 512);
  63.     GroupKeywordString[0] = '\0';
  64.     DemoKeywordString = (char *)malloc( sizeof(char) * 512);
  65.     DemoKeywordString[0] = '\0';
  66.     ExeFileString = (char *)malloc( sizeof(char) * 512);
  67.     ExeFileString[0] = '\0';
  68.     GroupKeywordCount = 0;
  69.     DemoKeywordCount = 0;
  70.     ExeFileCount = 0;
  71.  
  72.     CreateGroup = create_CreateGroup();
  73.     Index_w = create_Index();
  74.     AskDupIcons_w = create_AskDupIcons();
  75.     DupIcons_w = create_DupIcons();
  76.         Quit_w = create_Quit();
  77. }
  78.  
  79. Create_motif_widgets()
  80. {
  81.  
  82. Widget sw;
  83.  
  84.     sw = create_AddDemo();
  85.     sw = create_BookFile();
  86.     sw = create_Message();
  87.     sw = create_Question();
  88. }
  89.  
  90. handleMotifInterfaceEvents()
  91. {
  92.     XEvent event;
  93.  
  94.     while (XtAppPending(DBapp_context)) {
  95.       XtAppNextEvent(DBapp_context, &event);
  96.       XtDispatchEvent(&event);
  97.     }
  98. }
  99.  
  100. handleMessageEvents()
  101. {
  102.     XEvent event;
  103.  
  104.     UxWaitForNotify();
  105.     while (XtAppPending(DBapp_context)) {
  106.       XtAppNextEvent(DBapp_context, &event);
  107.       XtDispatchEvent(&event);
  108.     }
  109. }
  110.  
  111.  
  112. #include <ctype.h>
  113. #include <X11/StringDefs.h>
  114. #include <Xm/Xm.h>
  115. #include <Xm/Text.h>
  116. #include <varargs.h>
  117.  
  118. /* get normal string from XmString */
  119. char *extract_first_xms_segment(cs)
  120. XmString cs;
  121. {
  122.   XmStringContext context;
  123.   XmStringCharSet charset;
  124.   XmStringDirection direction;
  125.   Boolean separator;
  126.   char *primitive_string;
  127.  
  128.   XmStringInitContext(&context,cs);
  129.   XmStringGetNextSegment(context,&primitive_string,
  130.        &charset,&direction,&separator);
  131.   XmStringFreeContext(context);
  132.   return(primitive_string);
  133. }
  134.  
  135. /* find first normal string in XmString with a non-zero length */
  136. char *extract_nth_xms_segment(cs,seg_num)
  137. XmString cs;
  138. int seg_num;
  139. {
  140.   XmStringContext context;
  141.   XmStringCharSet charset;
  142.   XmStringDirection direction;
  143.   Boolean separator;
  144.   char *primitive_string;
  145.   int n;
  146.  
  147.   XmStringInitContext(&context,cs);
  148.   n=0;
  149.   do{
  150.     XmStringGetNextSegment(context,&primitive_string,
  151.        &charset,&direction,&separator);
  152.   }
  153.   while(n++<seg_num && primitive_string && !strlen(primitive_string));
  154.   XmStringFreeContext(context);
  155.   return(primitive_string);
  156. }
  157.  
  158.  
  159. #include <Xm/MwmUtil.h>      /* mwm decoration */
  160.  
  161. SetWMhints(wgt)
  162.     Widget wgt;
  163. {
  164.     MwmHints     mwm_set_hints ;
  165.     Atom         mwm_hints ;
  166.     XWMHints     wm_set_hints;
  167.     XUnmapEvent  Unmap_ev;
  168.  
  169.     if (XmIsMotifWMRunning(wgt)) {
  170.     mwm_hints = XmInternAtom(UxDisplay, 
  171.                  "_MOTIF_WM_HINTS", False);
  172.     mwm_set_hints.flags = MWM_HINTS_DECORATIONS | MWM_HINTS_FUNCTIONS ;
  173.     mwm_set_hints.decorations = 
  174.         MWM_DECOR_ALL | 
  175.         MWM_DECOR_RESIZEH | MWM_DECOR_MENU |
  176.             MWM_DECOR_MINIMIZE | MWM_DECOR_MAXIMIZE ;
  177.     mwm_set_hints.functions = 
  178.         MWM_FUNC_ALL | 
  179.         MWM_FUNC_CLOSE | MWM_FUNC_QUIT_APP |
  180.             MWM_FUNC_MINIMIZE | MWM_FUNC_MAXIMIZE ;
  181.     XChangeProperty(UxDisplay,XtWindow(wgt),
  182.             mwm_hints,mwm_hints,
  183.             32, PropModeReplace,
  184.             (unsigned char *)&mwm_set_hints, 
  185.             sizeof(MwmHints)/sizeof(int));
  186.         wm_set_hints.flags = StateHint;
  187.         wm_set_hints.initial_state = NormalState;
  188.     XSetWMHints(UxDisplay, XtWindow(wgt), &wm_set_hints);
  189.     }
  190. }
  191.